version 13.0
log using "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\sentiment2.log", replace
#delimit ;


*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      sentiment2.do                                   *;
*       Date:           April 22, 2017                                  *;
*       Author:         MRG/CC                                          *;
*       Purpose:      	Data analysis replication file for the Online   *;
*                       Appendix that accompanies, It's Not Only What   *;
*                       You Say, It's Also How You Say It: The          *;
*                       Strategic Use Of Campaign Sentiment. Journal of *;
*                       Politics. Forthcoming                           *;
* 	    Input File:     sentiment.dta                                   *;
*       Output File:    sentiment2.log                                  *;
*       Data Output:    none                                            *;             
*       Previous file:  sentiment.dta                                   *;
*       Machine:        desktop/laptop                     				*;
*     ****************************************************************  *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*        Load data                                                      *;
*     ****************************************************************  *;

use "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\sentiment.dta", clear;

set more off;

desc;

sum;

*     ****************************************************************  *;
*       Generate additional variables that we will need for our         *;
*       analysis.                                                       *;
*     ****************************************************************  *;

gen incumbent_inflation_l = incumbent*inflation_l;
label var incumbent_inflation "incumbent*inflation_l";

gen incumbent_unemployment_l = incumbent*unemployment_l;
label var incumbent_unemployment_l "incumbent*unemployment_l";

gen incumbent_lrgpde_growth = incumbent*lrgdpe_growth;
label var incumbent_lrgpde_growth "incumbent*lrgpde_growth";

gen incumbent_lrgpdo_growth = incumbent*lrgdpo_growth;
label var incumbent_lrgpdo_growth "incumbent*lrgpdo_growth";

gen incumbent_pm = incumbent*pm;
label var incumbent_pm "incumbent*pm";

gen incumbent_fm = incumbent*fm;
label var incumbent_fm "incumbent*fm";
gen incumbent_pm_fm = incumbent_pm*incumbent_fm;
label var incumbent_pm_fm "incumbent_pm*incumbent_fm";

gen left_right2=left_right*left_right;
label var left_right2 "left_right*left_right";

gen extremist = 0;
replace extremist=1 if family_id ==14 | family_id==40;
replace extremist = . if family_id==.;
label var extremist "1 if communist/socialist or far right, 0 otherwise";

gen extremist2 = 0;
replace extremist2=1 if family_id ==14 | family_id==40 | family_id==19;
replace extremist2 = . if family_id==.;
label var extremist2 "1 if communist/socialist, far right, or greens, 0 otherwise";

desc;

sum;

xtset language;


*     ****************************************************************  *;
*       Online Appendix A: Table 1 -- Check finance minister            *;
*     ****************************************************************  *;

tab pm fm if incumbent==1;

* Model 1*;
bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_fm, fe;

* Model 2 *;
bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm incumbent_fm, fe;

* Model 3 *;
bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm incumbent_fm incumbent_pm_fm, fe;

*     ****************************************************************  *;
*       No evidence that finance minister matters, PM party still       *;
*       matters.                                                        *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Online Appendix B: Replication can be found in                  *;
*       figure1_appendix.do                                             *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Online Appendix C: Fixed effects                                *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Least squares dummy variable version of the fixed effects model *;
*       Table 2: Language fixed effects                                 *;
*     ****************************************************************  *;

tabulate language, gen(l);

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm left_right left_right2  l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist  l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist inflation_l l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist unemployment_l l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist lrgdpe_growth l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist inflation_l incumbent_inflation_l l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist unemployment_l incumbent_unemployment_l l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist lrgdpe_growth incumbent_lrgpde_growth l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist inflation_l incumbent_inflation_l unemployment_l incumbent_unemployment_l lrgdpe_growth incumbent_lrgpde_growth l1 l2 l3 l4 l5 l6 l7, noconstant;
testparm l1 l2 l3 l4 l5 l6 l7; 

*     ****************************************************************  *;
*       Least squares dummy variable version of the fixed effects model *;
*       Table 3: Country fixed effects                                  *;
*     ****************************************************************  *;

tabulate cow, gen(c);

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm left_right left_right2  c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist  c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist inflation_l c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist unemployment_l c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist lrgdpe_growth c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist inflation_l incumbent_inflation_l c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist unemployment_l incumbent_unemployment_l c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist lrgdpe_growth incumbent_lrgpde_growth c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

bootstrap, reps(400) seed(10101) cluster(election_id): reg positive_sentiment incumbent incumbent_pm extremist inflation_l incumbent_inflation_l unemployment_l incumbent_unemployment_l lrgdpe_growth incumbent_lrgpde_growth c1 c2 c3 c4 c5 c6 c7 c8, noconstant;
testparm c1 c2 c3 c4 c5 c6 c7 c8; 

*     ****************************************************************  *;
*       Robustness Check: Different measure of extremist party that     *;
*       includes greens                                                 *;
*     ****************************************************************  *;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2 inflation_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2 unemployment_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2 lrgdpe_growth, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2 inflation_l incumbent_inflation_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2 unemployment_l incumbent_unemployment_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2 lrgdpe_growth incumbent_lrgpde_growth, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist2 inflation_l incumbent_inflation_l unemployment_l incumbent_unemployment_l lrgdpe_growth incumbent_lrgpde_growth, fe;

*     ****************************************************************  *;
*       Results are robust                                              *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Robustness Check: No clustering                                 *;
*     ****************************************************************  *;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm left_right left_right2, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm extremist, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm extremist inflation_l, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm extremist unemployment_l, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm extremist lrgdpe_growth, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm extremist inflation_l incumbent_inflation_l, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm extremist unemployment_l incumbent_unemployment_l, fe;

bootstrap, reps(400) seed(10101): xtreg positive_sentiment incumbent incumbent_pm extremist lrgdpe_growth incumbent_lrgpde_growth, fe;

*     ****************************************************************  *;
*       Results are robust                                              *;
*     ****************************************************************  *; 

*     ****************************************************************  *;
*       In our response memo, we also ran a model where we assume that  *;
*       positive sentiment declines linearly from the center of the     *;
*       policy space.  This is captured by extremist3. We're expecting  *;
*       a negative and significant coefficient on extremist3.           *;
*     ****************************************************************  *;

gen extremist3 = abs(5-left_right);

order left_right extremist3, last;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist3, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist3 inflation_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist3 unemployment_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist3 inflation_l incumbent_inflation_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist3 unemployment_l incumbent_unemployment_l, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist3 lrgdpe_growth incumbent_lrgpde_growth, fe;

bootstrap, reps(400) seed(10101) cluster(election_id): xtreg positive_sentiment incumbent incumbent_pm extremist3 inflation_l incumbent_inflation_l unemployment_l incumbent_unemployment_l lrgdpe_growth incumbent_lrgpde_growth, fe;

*     ****************************************************************  *;
*       Replication complete                                            *;
*     ****************************************************************  *;

log close;

clear;

